package com.jboost.hyk.common.entity;


import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.jboost.common.system.base.entity.JBoostEntity;

/**
 * @Description: 机构知识点
 * @Author: cxn
 * @Date:   2022-10-22
 * @Version: V1.0
 */
@Data
@TableName("hyk_business_point")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="hyk_business_point对象", description="机构知识点")
public class BusinessPoint extends JBoostEntity{

    /**所属机构*/
    @ApiModelProperty(value = "所属机构")
    private String businessId;

    /**来源订单*/
    @ApiModelProperty(value = "来源订单")
    private String orderId;

    @ApiModelProperty(value = "订单商品类型：package-套餐")
    private String itemType;

    /**知识点总数*/
    @ApiModelProperty(value = "知识点总数")
    private Integer total;

    /**已使用数量*/
    @ApiModelProperty(value = "已使用数量")
    private Integer used;

    /**类型：fixed_time:固定时长；auto:自动生效；*/
    @ApiModelProperty(value = "类型：fixed_time:固定时长；auto:自动生效；")
    private String type;

    /**生效时间，只有自动生效才有值*/
    @ApiModelProperty(value = "生效时间，只有自动生效才有值")
    private java.util.Date validTime;

    /**失效时间，只有自动生效才有值*/
    @ApiModelProperty(value = "失效时间，只有自动生效才有值")
    private java.util.Date invalidTime;
    @ApiModelProperty(value = "有效时长（月）")
    private Integer validMonth;

    public int surplusNum() {
        if (null == total || total == 0){
            return 0;
        }
        return total-used;
    }
    public int validNum(){
        return this.total - this.used;
    }
}
